//@author A0081229H
package storage;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class StorageTester {

	public static void main(String[] args) throws NumberFormatException, Exception {
		// Unit testing for creation of Time class
		// Can be tweaked for Date by changing the variables as follows
		// Can be further extended to test other components of Attribute classes
				
		final int maxHours = 24; // remove this component for Date
		final int maxMinSec = 60; // split into maxMonth = 12 and maxDay = 31
		
		Time t;

		Integer h1 = -1; // invalid; negative partition
		Integer h2 = maxHours - 1; // valid; boundary partition
		Integer h3 = maxHours; // invalid; out-of-bounds partition
		Integer h4 = null; // invalid; null partition

		Integer m1 = -1; // invalid; negative partition
		Integer m2 = maxMinSec - 1; // valid; boundary partition
		Integer m3 = maxMinSec; // invalid; out-of-bounds partition
		Integer m4 = null; // invalid; null partition

		boolean b = true;

		//Case 1: valid combination 1
		try {
			t = new Time(h2, m2);
		} catch (Exception e) {
			System.out.println("Case 1 failed.");
			b = false;
		}
		if (b) {System.out.println("Case 1 succeeded.");}

		//Case 2: valid combination 2
		try {
			t = new Time(h2);
		} catch (Exception e) {
			System.out.println("Case 2 failed.");
			b = false;
		}
		if (b) {System.out.println("Case 2 succeeded.");}

		// Case 3: h1 test
		try {
			t = new Time(h1, m2);
		} catch (Exception e) {
			System.out.println("Case 3 succeeded.");
		}

		// Case 4: h3 test
		try {
			t = new Time(h3, m2);
		} catch (Exception e) {
			System.out.println("Case 4 succeeded.");
		}

		// Case 5: h4 test
		try {
			t = new Time(h4, m2);
		} catch (Exception e) {
			System.out.println("Case 5 succeeded.");
		}
		// Case 6: m1 test
		try {
			t = new Time(h2, m1);
		} catch (Exception e) {
			System.out.println("Case 6 succeeded.");
		}

		// Case 7: m3 test
		try {
			t = new Time(h2, m3);
		} catch (Exception e) {
			System.out.println("Case 7 succeeded.");
		}

		// Case 8: m4 test
		try {
			t = new Time(h2, m4);
		} catch (Exception e) {
			System.out.println("Case 8 succeeded.");
		}
		
		BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("file.txt"))));
		String cLine;
		while ((cLine = br.readLine()) != null) {
			System.out.println(cLine);
		}
		
		PrintWriter pw = new PrintWriter(new FileWriter("file2.txt"));
		Integer i = 50;
		pw.write(i.toString());
		pw.close();
	

	}

}
